Phase 2: Dashboard frontend with public metrics and community tabs#140
Merged
neuromechanist merged 6 commits intoFeb 3, 2026
Conversation
- Add public query functions (no tokens/costs/models exposed) - Create /metrics/public/* endpoints (no auth required) - Build /dashboard page with Chart.js, community tabs, admin unlock - Register new routers in main.py - Add tests for public endpoints and dashboard page (28 new tests)
- Move per-community public metrics to community router
(/{community_id}/metrics/public, /{community_id}/metrics/public/usage)
- Keep only global /metrics/public/overview in metrics_public router
- Remove FastAPI dashboard router
- Add dashboard/ as standalone static site for Cloudflare Pages:
/ = aggregate overview, /{community} = community detail
- Client-side routing with configurable API base URL
- Add _redirects for Cloudflare Pages SPA routing
- Update tests for new route structure
Deploys dashboard/ to osa-dash.pages.dev via wrangler.
Same pattern as existing deploy-pages.yml for the demo widget:
- main -> osa-dash.pages.dev (production)
- develop -> develop.osa-dash.pages.dev
- PRs -> {branch}.osa-dash.pages.dev with preview URL comment
Tabs are populated from /metrics/public/overview API so new
communities appear automatically. Navigation uses simple links
(All -> /, community -> /{id}) with active tab highlighting.
Contributor
Dashboard Preview
This preview will be updated automatically when you push new commits. |
- Fix XSS: add escapeHtml() helper, sanitize all innerHTML interpolations, use encodeURIComponent() for URL path segments - Move get_metrics_connection() inside try blocks in all metrics endpoints - Add console.error/warn to all JavaScript catch blocks (no silent failures) - Improve admin section UX: defer visibility until data loads successfully - Extract shared helpers in queries.py (_count_tools, _validate_period) - Add test classes: TestPublicAdminBoundary, TestEmptyDatabase, TestCommunityMetricsValues with dynamic community cross-checks - Fix admin boundary tests to use auth_env fixture with test API key
- Fix single-quote XSS in onclick handlers: use encodeURIComponent for communityId in changePeriod calls, decode in changePeriod - Validate health status against known values instead of escapeHtml - Add console.warn to sync/health .catch() blocks - Add console.error to loadCommunityView catch block - Add auth-enabled tests proving public endpoints stay accessible when REQUIRE_API_AUTH=true (core security contract) - Add metrics_connection() context manager in db.py; simplify all endpoint handlers from nested try/try/finally to with-statement - Use tuple unpacking in _count_tools for clarity
0253e54
into
feature/issue-132-epic-community-dashboard
4 checks passed
This was referenced Feb 3, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dashboard/index.html) deployed to Cloudflare Pages atosa-dash.pages.dev/for aggregate overview,/{community}for per-community detailCloses #135
New files
src/api/routers/metrics_public.py- Global public overview endpointsrc/metrics/queries.py- 3 public query functions (overview, community summary, usage stats)dashboard/index.html- Standalone static dashboard with Chart.jsdashboard/_redirects- Cloudflare Pages SPA routing.github/workflows/deploy-dashboard.yml- CI for dashboard deploystests/test_api/test_metrics_public.py- 17 tests for public endpointstests/test_api/test_dashboard.py- 15 tests for static HTML contentModified files
src/api/routers/community.py- Added per-community/metrics/publicand/metrics/public/usageendpointssrc/api/main.py- Registeredmetrics_public_routersrc/api/routers/__init__.py- Exported new routerTest plan
test_metrics_public.py+test_dashboard.py)